﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BigData.DataContracts.Objects.Reddit;
using BigData.DataContracts.Objects.BigData;
using BigDataFramework.Repositories;
using MongoDB.Bson;
using BigData.DataContracts.Objects.BigData.BaseTypes;

namespace BigDataFramework.Library.Objects.DataAdapters.Reddit
{
    public abstract class RedditAdapterBase<T> : DataAdapterBase<T>
        where T : BigDataDBObject_FiniteLife
    {
        public RedditAdapterBase()
            : base() { }

        public BigDataUserToRedditUserData RetrieveRedditUserIdForBigDataUserId(BigDataUser user)
        {
            return this._dbContext.ReadOne<BigDataUserToRedditUserData>(bdutrud => bdutrud.BigDataUserId == ObjectId.Parse(user._id));
        }

        public List<T> GetAll<T>(BigDataUser user, DateTime startDate, DateTime endDate, RestSharp.RestRequest request)
            where T : UserCreatedThing
        {
            List<T> output = RedditAdapter.GetAll<T>(startDate, endDate, request);

            // Add big data info to each record
            foreach (T obj in output)
                obj.AssociatedUserIds = new List<string> { user._id };

            return output;
        }
    }
}
